﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using PH.Model.Schools;
namespace PH.Data.Schools
{
    public class SchoolTypeCommand
    {
        public static SchoolTypeCollection GetAll()
        {
            var ret = new SchoolTypeCollection();
            using (DBCentre db = new DBCentre())
            {
                IQueryable<SchoolType> q = db.DataContext.SchoolTypes;
                var n = q.Count();
                if (n > 0)
                {
                    q = q.OrderBy(p => p.ID);
                    var lst = q.ToList();
                    ret = Convertor.ConvertCollection<SchoolTypeModel, SchoolType, SchoolTypeCollection>(lst);
                    ret.TotalRecordsCount = n;
                }
            }
            return ret;
        }
    }
}
